﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Snake1._0
{
    public class PedacoSnake : DrawableGameComponent
    {

        bool _isCabeca = false;
        bool _isRabo = false;
        Vector2 _posicao;
        SpriteBatch _spriteBatch;
        Texture2D _texture;
        Game _game;

        public float Tamanho
        {
            get { return _texture.Height; }
        }

        #region Properties
        public bool IsCabeca
        {
            get { return _isCabeca; }
            set { _isCabeca = value; }
        }
        public bool IsRabo
        {
            get { return _isRabo; }
            set { _isRabo = value; }
        }
        public Vector2 Posicao
        {
            get { return _posicao; }
            set { _posicao = value; }
        }
        #endregion        

        public PedacoSnake(Game game, Vector2 posicao)
            : base(game)
        {
            _posicao = posicao;
            _game = game;

            _spriteBatch = (SpriteBatch)_game.Services.GetService(typeof(SpriteBatch));            
        }

        protected override void LoadContent()
        {
            if (IsCabeca)
                _texture = _game.Content.Load<Texture2D>("snakeHeaddireita");
            else if(IsRabo)
                _texture = _game.Content.Load<Texture2D>("snakeCorpo");
            else
                _texture = _game.Content.Load<Texture2D>("snakeCorpo");

            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            LoadContent();

            _spriteBatch.Draw(_texture, _posicao, Color.White);

            base.Draw(gameTime);
        }
    }
}
